package what.basic.xml;
import javax.xml.parsers.*;
import org.w3c.dom.*;
public class xmldom {
	public static void main(String[] args) throws Exception{
		xmldom dt=new xmldom("e:\\1.xml");
	}
	public xmldom(String uri) throws Exception{
		DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
		factory.setValidating(true);
		DocumentBuilder builder=factory.newDocumentBuilder();
		Document doc=builder.parse(uri);
		displaytree(doc.getDocumentElement().getFirstChild());
	}
	protected void displaytree(Node node){
		short nodeType=node.getNodeType();
		switch(nodeType){
		case Node.ELEMENT_NODE:
			printElement((Element)node);
			break;
		default:
		}
	}
	protected void printElement(Element node){
		System.out.println(node.getNodeName());
	}
}
